from configparser import ConfigParser
import os

# 获取项目绝对路径
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))

class GETPath:
    def __init__(self):

        # 实例化读取ini文件的类
        self.config = ConfigParser()
        # 获取path.ini文件完整路径
        pathini_path = os.path.join(base_path, "config\path.ini")
        # 进行文件读取
        with open(pathini_path, encoding="utf-8") as fp:
            self.config.read_file(fp)

    def getpath(self,path):
        """

        :return:
        """
        relative_path = self.config.get("path", path)
        return os.path.join(base_path, relative_path)

if __name__ == "__main__":
   print(GETPath().getpath('config_path'))
   print()
